using System;
using System.Collections.Generic;
using System.Text;
using BusinessObjects.BO_Actions.Members;
using Entity.StoreProcedure;
using BusinessObjects;
using System.Data;
using BusinessObjects;
using BussinessObjects.BO_Actions;
using BussinessObjects.BO_Actions.Members;

namespace BusinessObjects.BO_GetObjects
{
    public static class BO_Members
    {
        public static DataTable SelectAll(int status)
        {
            try
            {
                BOMembers_Select_All action = new BOMembers_Select_All();
                usp_Members_Select_All entity = new usp_Members_Select_All();
                entity.STATUS = status;

                return action.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable Login(string user, string password)
        {
            try
            {
                BOMemberLogin action = new BOMemberLogin();
                usp_MemberLogin entity = new usp_MemberLogin();
                entity.USERNAME = user;
                entity.PASSWORD = password;

                return action.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable SelectTop(int rows, int status)
        {
            try
            {
                BOMembers_Select_Top action = new BOMembers_Select_Top();
                usp_Members_Select_Top entity = new usp_Members_Select_Top();
                entity.NUMBERRECORD = rows;
                entity.STATUS = status;

                return action.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable Search(int member_id)
        {
            try
            {
                BOMembers_Search action = new BOMembers_Search();
                usp_Members_Search entity = new usp_Members_Search();
                entity.MEMBER_ID = member_id;

                return action.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable SearchByName(string user_name)
        {
            try
            {
                BOMembers_Search_By_Name action = new BOMembers_Search_By_Name();
                usp_Members_Search_By_Name entity = new usp_Members_Search_By_Name();
                entity.USER_NAME = user_name;

                return action.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable SearchByCode(string member_code)
        {
            try
            {
                BOMembers_Search_By_Code action = new BOMembers_Search_By_Code();
                usp_Members_Search_By_Code entity = new usp_Members_Search_By_Code();
                entity.MEMBER_CODE = member_code;

                return action.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable SelectWithPaged(int startIndex, int pageCount, int status)
        {
            try
            {
                BOMembers_Select_WithPaged action = new BOMembers_Select_WithPaged();
                usp_Members_Select_WithPaged entity = new usp_Members_Select_WithPaged();
                entity.STARTINDEX = startIndex;
                entity.MAXRECORDS = pageCount;
                entity.STATUS = status;

                return action.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable SearchLike(string keyword, int startIndex, int pageCount, int status)
        {
            try
            {
                BOMembers_Search_Like action = new BOMembers_Search_Like();
                usp_Members_Search_Like entity = new usp_Members_Search_Like();
                entity.KEYWORD = keyword;
                entity.STARTINDEX = startIndex;
                entity.MAXRECORDS = pageCount;
                entity.STATUS = status;

                return action.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static string Insert(string user_name, string pass_word, string member_code, string full_name, string company_name, string address, string nick_yahoo, string nick_skype, bool is_receive_news_letter, string mobile, bool is_vip, bool is_active, bool on_mobile, DateTime created_date, string created_by, DateTime modify_date, string modify_by, int status)
        {
            try
            {
                BOMembers_Insert action = new BOMembers_Insert();
                usp_Members_Insert entity = new usp_Members_Insert();
                entity.USER_NAME = user_name;
                entity.PASS_WORD = pass_word;
                entity.MOBILE = mobile;
                entity.IS_ACTIVE = is_active;
                entity.ON_MOBILE = on_mobile;
                entity.CREATED_DATE = created_date;
                entity.CREATED_BY = created_by;
                entity.MODIFY_DATE = modify_date;
                entity.MODIFY_BY = modify_by;
                entity.STATUS = status;
                entity.MEMBER_CODE = member_code;
                entity.IS_VIP = is_vip;
                entity.FULL_NAME = full_name;
                entity.COMPANY_NAME = company_name;
                entity.ADDRESS = address;
                entity.NICK_YAHOO = nick_yahoo;
                entity.NICK_SKYPE = nick_skype;
                entity.IS_RECEIVE_NEWSLETTER = is_receive_news_letter;
                return action.ExecuteAndReturnStringValue(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static string ExitsMobile(string mobile)
        {
            try
            {
                BOMembers_Exist_Mobile action = new BOMembers_Exist_Mobile();
                usp_Members_Exist_Mobile entity = new usp_Members_Exist_Mobile();
                entity.MOBILE = mobile;
                return action.ExecuteAndReturnStringValue(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static string Update(Int64 member_id, string user_name, string pass_word, string mobile, bool is_active, DateTime created_date, string created_by, DateTime modify_date, string modify_by, int status)
        {
            try
            {
                BOMembers_Update action = new BOMembers_Update();
                usp_Members_Update entity = new usp_Members_Update();
                entity.MEMBER_ID = member_id;
                entity.USER_NAME = user_name;
                entity.PASS_WORD = pass_word;
                entity.MOBILE = mobile;
                entity.IS_ACTIVE = is_active;
                entity.CREATED_DATE = created_date;
                entity.CREATED_BY = created_by;
                entity.MODIFY_DATE = modify_date;
                entity.MODIFY_BY = modify_by;
                entity.STATUS = status;

                return action.ExecuteAndReturnStringValue(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static string UpdateVip(Int64 member_id, bool is_vip, DateTime modify_date, string modify_by)
        {
            try
            {
                BOMembers_Update_Vip action = new BOMembers_Update_Vip();
                usp_Members_Update_Vip entity = new usp_Members_Update_Vip();
                entity.MEMBER_ID = member_id;
                entity.MODIFY_DATE = modify_date;
                entity.MODIFY_BY = modify_by;
                entity.IS_VIP = is_vip;

                return action.ExecuteAndReturnStringValue(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public static string UpdatePassword(string user_name, string pass_word)
        {
            try
            {
                BOMembers_Update_Password action = new BOMembers_Update_Password();
                usp_Member_Update_Password entity = new usp_Member_Update_Password();
                entity.USERNAME = user_name;
                entity.PASSWORD = pass_word;

                return action.ExecuteAndReturnStringValue(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static bool Delete(int member_id)
        {
            try
            {
                BOMembers_Delete action = new BOMembers_Delete();
                usp_Members_Delete entity = new usp_Members_Delete();
                entity.MEMBER_ID = member_id;

                return action.ExecuteAndReturnBooleanValue(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static bool IsVip(int member_id)
        {
            try
            {
                BOMembers_Is_Vip action = new BOMembers_Is_Vip();
                usp_Members_Is_Vip entity = new usp_Members_Is_Vip();
                entity.MEMBER_ID = member_id;
                return action.ExecuteAndReturnBooleanValue(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static bool IsActive(int member_id)
        {
            try
            {
                BOMembers_Is_Active action = new BOMembers_Is_Active();
                usp_Members_Is_Active entity = new usp_Members_Is_Active();
                entity.MEMBER_ID = member_id;
                return action.ExecuteAndReturnBooleanValue(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static bool Restore(int member_id)
        {
            try
            {
                BOMembers_Restore action = new BOMembers_Restore();
                usp_Members_Restore entity = new usp_Members_Restore();
                entity.MEMBER_ID = member_id;

                return action.ExecuteAndReturnBooleanValue(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static bool Activated(int member_id, bool isactivated)
        {
            try
            {
                BOMembers_Activated action = new BOMembers_Activated();
                usp_Members_Activated entity = new usp_Members_Activated();
                entity.MEMBER_ID = member_id;
                entity.ISACTIVATED = isactivated;

                return action.ExecuteAndReturnBooleanValue(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static string ExistMemberCode(string member_code)
        {
            try
            {
                BOMembers_Exist_Member_Code action = new BOMembers_Exist_Member_Code();
                usp_Members_Exist_Member_Code entity = new usp_Members_Exist_Member_Code();
                entity.MEMBER_CODE = member_code;

                return action.ExecuteAndReturnStringValue(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    }
}

